<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <div
      class="content-parent border-hover-style"
      :style="{ backgroundImage: `url(${publicUrls + 'free/style3/Auxiliaryoutlinestyle4Bg1.webp'})` }"
    >
      <div
        class="content-box"
        :style="{ backgroundImage: `url(${publicUrls + 'free/style3/Auxiliaryoutlinestyle4Bg2.webp'})` }"
      >
        <div
          class="audio-box"
          :class="isPlay && 'audio-rotate'"
          v-if="props.info.audio && props.info.audio.url"
          @click="audioplay(true)"
        >
          <i class="doorIcon">&#xe688;</i>
        </div>
        <audio
          v-if="props.info.audio && props.info.audio.url"
          :src="urls + props.info.audio.url"
          ref="audioRef"
        ></audio>
        <div class="top-box">
          <p class="title-name">{{ props.info.text }}</p>
          <p class="subtitle" v-if="props.info.subTitle">
            {{ props.info.subTitle }}
          </p>
          <div
            class="top-box-bg"
            :style="{ backgroundImage: `url(${publicUrls + 'free/style3/Auxiliaryoutlinestyle4Bg3.webp'})` }"
          ></div>
        </div>
        <div
        v-if="(props.info.value || (props.info.video && props.info.video.url)) && props.info.remarks"
          class="content"
          :class="{
            content1: (props.info.value || (props.info.video && props.info.video.url)) && !props.info.remarks,
            content2: !(props.info.value || (props.info.video && props.info.video.url)) && props.info.remarks,
          }"
        >
          <div class="img-box" v-if="props.info.value || (props.info.video && props.info.video.url)">
            <videoview
              @click="audioplay(false)"
              :info="props.info"
              v-if="props.info.video && props.info.video.url"
            ></videoview>
            <img
              v-else
              class="outline-cover"
              @click="ImgVisible = true"
              :src="urls + props.info.value + '?imageView2/3/format/webp'"
              alt=""
            />
          </div>

          <div class="remarks" v-if="props.info.remarks">
            <TextMax
              :infoData="props.info"
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :row="6"
            ></TextMax>
          </div>
        </div>
        <div
        v-else
          class="content"
          :class="{
            content1: (props.info.value || (props.info.video && props.info.video.url)) && !props.info.remarks,
            content2: !(props.info.value || (props.info.video && props.info.video.url)) && props.info.remarks,
          }"
        >
          <div class="img-box" v-if="props.info.value || (props.info.video && props.info.video.url)">
            <videoview
              @click="audioplay(false)"
              :info="props.info"
              v-if="props.info.video && props.info.video.url"
            ></videoview>
            <img
              v-else
              class="outline-cover"
              @click="ImgVisible = true"
              :src="urls + props.info.value + '?imageView2/3/format/webp'"
              alt=""
            />
          </div>

          <div class="remarks" v-if="props.info.remarks">
            <TextMax
              :infoData="props.info"
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :row="6"
            ></TextMax>
          </div>
        </div>
      </div>

      <!-- <img class="solid" :src="publicUrls + 'free/style3/Level2outlineStyle2xt.png'" alt="" /> -->
    </div>
  </div>
</template>
 


<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax3.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  display: flex;
  position: relative;
  margin-right: 140px;
  margin-top: 0;
  height: 100%;
}
.content-parent {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: 138px;
  width: 800px;
  height: 588px;
  background-repeat: no-repeat;
  background-size: 100% 100%;

  padding: 131px 50px 0 60px;
}
.content-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center; 
  width: 690px; 
  height: 427px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  -webkit-box-reflect: below 60% linear-gradient(transparent, rgba(0, 0, 0, 0.1));
  padding: 37px 20px 37px 10px;
}
.audio-box {
  position: absolute;
  top: 20px;
  right: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #ece5d9;
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  border: 2px solid #623333;
  border-radius: 50%;
  .doorIcon {
    font-size: 24px;
    color: rgba(98, 51, 51, 1);
  }
  z-index: 22;
}
.top-box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  height: 126px;
  width: 660px;
  padding-bottom: 48px;
}
.title-name {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  background: #e1dbcf;
  font-family: SourceBold;
  font-size: 20px;
  color: #2f1b16;
  line-height: 30px;
}
.top-box-bg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 660px;
  height: 48px;
  object-fit: contain;
}
.subtitle {
  width: 100%;
  height: 24px;
  font-family: SourceMedium;
  font-size: 18px;
  color: #2f1b16;
  line-height: 24px;
  text-align: center;
  opacity: 0.5;
  margin-top: 12px;
}

.content {
  position: relative;
  display: flex;
  align-items: center;
  width: 620px;
  height: 214px;
  margin-top: 12px;
  justify-content: space-between;
}
.content1 {
  .img-box {
    width: 620px;
  }
  .remarks {
    display: none;
  }
}
.content2 {
  .img-box {
    display: none;
  }
  .remarks {
    width: 620px;
  }
}
.img-box {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  width: 318px;
  height: 214px;
  background: #623333;
  border-radius: 8px 8px 8px 8px;
  // border-radius: 8px;
}
.outline-cover {
  height: 214px;
  width: 100%;
  object-fit: contain;
  transition: all 0.3s;
}
.outline-cover:hover {
  transform: scale(1.1);
}
.remarks {
  width: 292px;
}
.content1 {
}
.content2 {
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
</style>
